package com.example.pet.util;

import java.io.Serializable;

public class Response<T> implements Serializable {

    private boolean result;

    private T data;

    private String msg;

    public boolean isResult() {
        return result;
    }

    public void setResult(boolean result) {
        this.result = result;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public static <T> Response<T> result(boolean result, T data, String msg) {
        Response<T> responseVo = new Response<>();
        responseVo.setResult(result);
        responseVo.setData(data);
        responseVo.setMsg(msg);
        return responseVo;
    }

    public static <T> Response<T> result(boolean result, String msg) {
        return result(result,null,msg);
    }

    public static <T> Response<T> result(boolean result) {
        return result(result,null,null);
    }

    public static <T> Response<T> success(T data, String msg) {
        return result(true,data,msg);
    }

    public static <T> Response<T> success(T data) {
        return result(true,data,null);
    }

    public static Response success() {
        return result(true,null,null);
    }

    public static <T> Response<T> fail(T data, String msg) {
        return result(false,data,msg);
    }

    public static <T> Response<T> fail(String msg) {
        return result(false,null,msg);
    }

    public static <T> Response<T> fail() {
        return result(false,null,null);
    }
}
